package com.rear.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import com.rear.dao.AppMessageDao;
import com.rear.entity.AppMessageEntity;
import com.rear.service.AppMessageService;
import com.rear.utils.AppUtils;



@Service("appMessageService")
public class AppMessageServiceImpl implements AppMessageService {
	@Autowired
	private AppMessageDao appMessageDao;
	
	@Override
	public AppMessageEntity queryObject(Integer id){
		return appMessageDao.queryObject(id);
	}
	
	@Override
	public List<AppMessageEntity> queryList(Map<String, Object> map){
		return appMessageDao.queryList(map);
	}
	
	@Override
	public int queryTotal(Map<String, Object> map){
		return appMessageDao.queryTotal(map);
	}
	
	@Override
	public void save(AppMessageEntity appMessage){
		
		appMessage.setAppid(AppUtils.getAppKey());
		
		appMessage.setKey(AppUtils.getSalt());
		
		appMessageDao.save(appMessage);
	}
	
	@Override
	public void update(AppMessageEntity appMessage){
		appMessageDao.update(appMessage);
	}
	
	@Override
	public void delete(Integer id){
		appMessageDao.delete(id);
	}
	
	@Override
	public void deleteBatch(Integer[] ids){
		appMessageDao.deleteBatch(ids);
	}

	@Override
	public String uniqueIDToID(String uniqueID) {
		List<AppMessageEntity>appMessageEntitylist=appMessageDao.uniqueIDToID(uniqueID);
		if(appMessageEntitylist.isEmpty()){
			return null;
		}else{
			if(ObjectUtils.isEmpty(appMessageEntitylist.get(0))){
				return null;
			}else{
				return appMessageEntitylist.get(0).getId().toString();
			}	
		}
	}
}
